#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ************************************************************************ 
# * @File       : scripts/gen-version.py 
# * @Author     : LuoQiaoFa@163.com 
# * @Date       : 2023-06-08 09:14 
# * @Version    : 1.0  
# * @Description: Python Script 
# * @License    : Copyright (C) 2023-, LuoQiaoFa all rights reserved 
#************************************************************************* 
import sys
import os
import os.path
import time

if __name__ == '__main__' :
    argc = len(sys.argv)
            
    ts = time.strftime("%Y-%m-%d %H:%M:%S")
    vertxt ="/* Note This file is generated by tools, don't modify it */\n"
    vertxt += """#include <stdio.h>
#include <string.h>
extern int Printf(const char *fmt, ...);

int version(void)
{
"""
    vertxt += "    Printf(\"\\n############################################\\n\");\n"
    vertxt += "    Printf(\"# RTOS: luos, version: " + ts + " #\\n\");\n"
    vertxt += "    Printf(\"############################################\\n\\n\");\n"
    vertxt += """
    return 0;
}
"""
    if (argc > 1):
        fobj = open(sys.argv[1], "wb");
        if fobj:
            fobj.write(vertxt.encode('utf-8'))
            fobj.close()
    else:
        print(vertxt)
    pass

